﻿using ASPItalia.ModelVirtualCasting.WPF.ViewModels;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Windows.Input;
using System.Threading;
using System.ComponentModel;

namespace ASPItalia.ModelVirtualCasting.WPF.ViewModels.Test
{


    /// <summary>
    ///This is a test class for RecordViewModelTest and is intended
    ///to contain all RecordViewModelTest Unit Tests
    ///</summary>
    [TestClass()]
    public class RecordViewModelTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        [TestMethod()]
        [DeploymentItem("ASPItalia.ModelVirtualCasting.WPF.ViewModels.dll")]
        public void InitTest()
        {
            using (RecordViewModel target = new RecordViewModel())
            {
                Assert.IsFalse(target.IsPreparing, "IsPreparing is not false on initial state");
                Assert.IsFalse(target.IsRecording, "IsRecording is not false on initial state");
                Assert.IsNull(target.Multimedia, "Multimedia should be null initialy");
            }
        }

        /// <summary>
        ///A test for RecordCommand
        ///</summary>
        [TestMethod()]
        [DeploymentItem("ASPItalia.ModelVirtualCasting.WPF.ViewModels.dll")]
        public void RecordCommandTest()
        {
            using (RecordViewModel target = new RecordViewModel())
            {
                Assert.IsNotNull(target.RecordCommand, "RecordCommand is null");

                //// Start recording
                //target.RecordCommand.Execute(null);
                ////target.DoRecord(AsyncOperationManager.CreateOperation(null));

                //if (!AssertHelper.WairFor(target, t => t.IsRecording, TimeSpan.FromSeconds(5)))
                //    Assert.Fail("IsRecording should change to true");

                //// Stop recording
                //target.RecordCommand.Execute(null);
                ////target.StopRecord(AsyncOperationManager.CreateOperation(null));

                //if (!AssertHelper.WairFor(target, t => !t.IsRecording, TimeSpan.FromSeconds(5)))
                //    Assert.Fail("IsRecording should change to true");
            }
        }

        /// <summary>
        ///A test for StopRecord
        ///</summary>
        [TestMethod()]
        [DeploymentItem("ASPItalia.ModelVirtualCasting.WPF.ViewModels.dll")]
        public void StopRecordTest()
        {
            RecordViewModel_Accessor target = new RecordViewModel_Accessor();

            Assert.IsFalse(target.IsUploading, "IsUploading is not false on initial state");

            target.StopRecord(AsyncOperationManager.CreateOperation(null));

            Assert.IsNotNull(target.Multimedia, "Multimedia should be not null");
        }
    }
}
